'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-10-28 21:55:59
'''
#
# @lc app=leetcode.cn id=915 lang=python3
#
# [915] 分割数组
#

# @lc code=start
from typing import List
class Solution:
    def partitionDisjoint(self, A: List[int]) -> int:
        from sys import maxsize
        tmin = maxsize
        tmax = -maxsize
        lmax, lmin = [0]*len(A),[0]*len(A)
        
        for i, v in enumerate(A):
            tmax = max(tmax, v)
            lmax[i]=(tmax)
        for i in range(len(A)-1, -1, -1):
            tmin = min(tmin, A[i])
            lmin[i]=tmin
        print(lmax, lmin)
        for i in range(len(A)-1):
            if lmax[i]<=lmin[i+1]:
                return i+1

        
# @lc code=end

if __name__ == "__main__":
    solution = Solution()
    A = [5,0,3,8,6]
    print(solution.partitionDisjoint(A))